'use strict';

/**
 * Config for the router
 */
angular.module('app')
    .run(
        ['$rootScope', '$state', '$stateParams',
            function($rootScope, $state, $stateParams) {
                $rootScope.$state = $state;
                $rootScope.$stateParams = $stateParams;
            }
        ]
    )
    .config(
        ['$stateProvider', '$urlRouterProvider',
            function($stateProvider, $urlRouterProvider) {
                $urlRouterProvider.otherwise('/app/home/index');
                // $urlRouterProvider.when("", "access/signin");
                $stateProvider
                    .state('app', {
                        abstract: true,
                        url: '/app',
                        templateUrl: 'views/app.html'
                    })
                    .state('nav', {
                        url: '/nav',
                        template: '<div ui-view></div>',
                        templateUrl: 'views/nav/auditPage.html',
                        resolve: {
                            deps: ['uiLoad',
                                function(uiLoad) {
                                    return uiLoad.load(['css/directives/tabset.css']);
                                }
                            ]
                        }
                    })

                    .state('app.home', {
                        url: '/home',
                        template: '<div ui-view></div>'
                    })

                    .state('app.home.index', {
                        url: '/index',
                        templateUrl: 'views/home/index.html',
                        resolve: {
                            deps: ['uiLoad',
                                function(uiLoad) {
                                    return uiLoad.load(['js/controllers/home/index.js']);
                                }
                            ]
                        }
                    })

                    .state('app.suim', {
                        url: '/suim',
                        template: '<div ui-view></div>'
                    })
                    .state('app.suim.list', {
                        url: '/list',
                        templateUrl: 'views/suim/list.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/suim/list.js']);
                                    });
                                }
                            ]
                        }
                    })

                    .state('app.suim.menuNode', {
                        url: '/menuNode',
                        templateUrl: 'views/suim/menuNode.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/suim/menuNode.js']);
                                    });
                                }
                            ]
                        }
                    })

                    .state('app.suim.roleInfo', {
                        url: '/roleInfo',
                        templateUrl: 'views/suim/roleInfo.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/suim/roleInfo.js']);
                                    });
                                }
                            ]
                        }
                    })

                    .state('app.suim.userProfile', {
                        url: '/userProfile',
                        templateUrl: 'views/suim/userProfile.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/suim/userProfile.js']);
                                    });
                                }
                            ]
                        }
                    })

                    .state('app.suim.modifyPassword', {
                        url: '/modifyPassword',
                        templateUrl: 'views/suim/modifyPassword.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/suim/modifyPassword.js']);
                                    });
                                }
                            ]
                        }
                    })

                    .state('app.suim.roleOperator', {
                        url: '/roleOperator',
                        templateUrl: 'views/suim/roleOperator.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/suim/roleOperator.js']);
                                    });
                                }
                            ]
                        }
                    })

                    .state('app.suim.roleOperator2', {
                        url: '/roleOperator2',
                        templateUrl: 'views/test/roleOperatorTemp.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/test/roleOperatorTemp.js']);
                                    });
                                }
                            ]
                        }
                    })

                    .state('app.suim.parameters', {
                        url: '/parameters',
                        templateUrl: 'views/suim/systemParameters.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/suim/systemParameters.js']);
                                    });
                                }
                            ]
                        }
                    })

                
                    .state('app.suim.changePsw', {
                            url: '/changePsw',
                            templateUrl: 'views/suim/changePsw.html',
                            resolve: {
                                deps: ['$ocLazyLoad',
                                    function($ocLazyLoad) {
                                        return $ocLazyLoad.load('ui.select').then(function() {
                                            return $ocLazyLoad.load(['js/controllers/suim/changePsw.js']);
                                        });
                                    }
                                ]
                            }
                        })
                    
                    .state('access', {
                        url: '/access',
                        template: '<div ui-view class="fade-in sign-wrapper"></div>'
                    })

                    .state('access.signin', {
                        url: '/signin',
                        templateUrl: 'views/page_signin.html',
                        resolve: {
                            deps: ['uiLoad',
                                function(uiLoad) {
                                    return uiLoad.load(['js/controllers/signin.js']);
                                }
                            ]
                        }
                    })

                    .state('access.signout', {
                        url: '/signout',
                        templateUrl: 'views/page_signout.html',
                        resolve: {
                            deps: ['uiLoad',
                                function(uiLoad) {
                                    return uiLoad.load(['js/controllers/signout.js']);
                                }
                            ]
                        }
                    })


                    //新加菜单 

                    .state('app.house', {
                        url: '/house',
                        template: '<div ui-view></div>'
                    })

                    //房源综合管理列表
                    .state('app.house.houseManageList', {
                        url: '/houseManageList',
                        templateUrl: 'views/house/houseManageList.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/house/houseManageList.js']);
                                    });
                                }
                            ]
                        }
                    })

                    //初审审核列表
                    .state('app.house.firstExamine', {
                        url: '/firstExamine',
                        templateUrl: 'views/house/firstExamine.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/house/firstExamine.js']);
                                    });
                                }
                            ]
                        }
                    })

                    //装修评估列表
                    .state('app.house.decorationList', {
                        url: '/decorationList',
                        templateUrl: 'views/house/decorationList.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/house/decorationList.js']);
                                    });
                                }
                            ]
                        }
                    })

                    //终审审核列表
                    .state('app.house.finallyExamine', {
                        url: '/finallyExamine',
                        templateUrl: 'views/house/finallyExamine.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/house/finallyExamine.js']);
                                    });
                                }
                            ]
                        }
                    })

                    //高管审核列表
                    .state('app.house.seniorManagerExamine', {
                        url: '/seniorManagerExamine',
                        templateUrl: 'views/house/seniorManagerExamine.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/house/seniorManagerExamine.js']);
                                    });
                                }
                            ]
                        }
                    })

                    .state('app.house.houseDetails', {
                        url: '/houseDetails',
                        templateUrl: 'views/house/houseDetails.html',
                        resolve: {
                            deps: ['$ocLazyLoad',
                                function($ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(
                                        function() {
                                            return $ocLazyLoad.load('angularFileUpload').then(
                                                function() {
                                                    // return $ocLazyLoad.load('js/controllers/houseOwner/editHousePicsTemplet.js');
                                                    return $ocLazyLoad.load(['js/controllers/house/houseDetails.js']);

                                                });
                                        }
                                    );
                                }
                            ]
                        }
                    })

                    .state('app.house.houseDetailsReadonly', {
                        url: '/houseDetailsReadonly',
                        templateUrl: 'views/house/houseDetailsReadonly.html',
                        resolve: {
                            deps: ['$ocLazyLoad',
                                function($ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(
                                        function() {
                                            return $ocLazyLoad.load('angularFileUpload').then(
                                                function() {
                                                    // return $ocLazyLoad.load('js/controllers/houseOwner/editHousePicsTemplet.js');
                                                    return $ocLazyLoad.load(['js/controllers/house/houseDetailsReadonly.js']);

                                                });
                                        }
                                    );
                                }
                            ]
                        }
                    })

                    .state('app.landlord', {
                        url: '/landlord',
                        template: '<div ui-view></div>'
                    })

                    //房东综合管理页面
                    .state('app.landlord.landlordManage', {
                            url: '/landlordManage',
                            templateUrl: 'views/landlord/landlordManage.html',
                            resolve: {
                                deps: ['uiLoad',
                                    '$ocLazyLoad',
                                    function(uiLoad, $ocLazyLoad) {
                                        return $ocLazyLoad.load('ui.select').then(function() {
                                            return uiLoad.load(['js/controllers/landlord/landlordManage.js']);
                                        });
                                    }
                                ]
                            }
                        })
                        //房东详情页面

                    .state('app.landlord.landlordDetails', {
                        url: '/landlordDetails',
                        templateUrl: 'views/landlord/landlordDetails.html',
                        resolve: {
                            deps: ['$ocLazyLoad',
                                function($ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(
                                        function() {
                                            return $ocLazyLoad.load('angularFileUpload').then(
                                                function() {
                                                    return $ocLazyLoad.load(['js/controllers/landlord/landlordDetails.js']);
                                                });
                                        }
                                    );
                                }
                            ]
                        }
                    })


                    //职业房东详情页面
                    .state('app.landlord.landlordJobDetails', {
                            url: '/landlordJobDetails',
                            templateUrl: 'views/landlord/landlordJobDetails.html',
                            resolve: {
                                deps: ['$ocLazyLoad',
                                    function($ocLazyLoad) {
                                        return $ocLazyLoad.load('ui.select').then(
                                            function() {
                                                return $ocLazyLoad.load('angularFileUpload').then(
                                                    function() {
                                                        return $ocLazyLoad.load(['js/controllers/landlord/landlordJobDetails.js']);
                                                    });
                                            }
                                        );
                                    }
                                ]
                            }
                        })
                        //房东资质审核页面
                        .state('app.landlord.landlordCheckDetails', {
                            url: '/landlordCheckDetails',
                            templateUrl: 'views/landlord/landlordCheckDetails.html',
                            resolve: {
                                deps: ['$ocLazyLoad',
                                    function($ocLazyLoad) {
                                        return $ocLazyLoad.load('ui.select').then(
                                            function() {
                                                return $ocLazyLoad.load('angularFileUpload').then(
                                                    function() {
                                                        return $ocLazyLoad.load(['js/controllers/landlord/landlordCheckDetails.js']);
                                                    });
                                            }
                                        );
                                    }
                                ]
                            }
                        })


                    //职业房东资质审核页面
                    .state('app.landlord.landlordCheckJobDetails', {
                            url: '/landlordCheckJobDetails',
                            templateUrl: 'views/landlord/landlordCheckJobDetails.html',
                            resolve: {
                                deps: ['$ocLazyLoad',
                                    function($ocLazyLoad) {
                                        return $ocLazyLoad.load('ui.select').then(
                                            function() {
                                                return $ocLazyLoad.load('angularFileUpload').then(
                                                    function() {
                                                        return $ocLazyLoad.load(['js/controllers/landlord/landlordCheckJobDetails.js']);
                                                    });
                                            }
                                        );
                                    }
                                ]
                            }
                        })
                        //房东房源列表页面
                        .state('app.landlord.landlordList', {
                            url: '/landlordList',
                            templateUrl: 'views/landlord/landlordList.html',
                            resolve: {
                                deps: ['uiLoad',
                                    '$ocLazyLoad',
                                    function(uiLoad, $ocLazyLoad) {
                                        return $ocLazyLoad.load('ui.select').then(function() {
                                            return uiLoad.load(['js/controllers/landlord/landlordList.js']);
                                        });
                                    }
                                ]
                            }
                        })

                    //房东资质审核页面
                    .state('app.landlord.landlordReview', {
                        url: '/landlordReview',
                        templateUrl: 'views/landlord/landlordReview.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/landlord/landlordReview.js']);
                                    });
                                }
                            ]
                        }
                    })

                    //新加菜单 - 合同管理

                    .state('app.contract', {
                        url: '/contract',
                        template: '<div ui-view></div>'
                    })

                    //合同管理页面
                    .state('app.contract.contractList', {
                        url: '/contractList',
                        templateUrl: 'views/contract/contractList.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/contract/contractList.js']);
                                    });
                                }
                            ]
                        }
                    })

                    //新加菜单 

                    .state('app.loanOrder', {
                        url: '/loanOrder',
                        template: '<div ui-view></div>'
                    })

                    //放款订单综合管理列表
                    .state('app.loanOrder.loanList', {
                        url: '/loanList',
                        templateUrl: 'views/loanOrder/loanList.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/loanOrder/loanList.js']);
                                    });
                                }
                            ]
                        }
                    })

                    //订单审核列表
                    .state('app.loanOrder.loanExamineList', {
                        url: '/loanExamineList',
                        templateUrl: 'views/loanOrder/loanExamineList.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/loanOrder/loanExamineList.js']);
                                    });
                                }
                            ]
                        }
                    })

                    //订单放款列表
                    .state('app.loanOrder.orderExamineList', {
                        url: '/orderExamineList',
                        templateUrl: 'views/loanOrder/orderExamineList.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/loanOrder/orderExamineList.js']);
                                    });
                                }
                            ]
                        }
                    })

                    //放款审核详情
                    .state('app.loanOrder.loanDetails', {
                        url: '/loanDetails',
                        templateUrl: 'views/loanOrder/loanDetails.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/loanOrder/loanDetails.js']);
                                    });
                                }
                            ]
                        }
                    })

                    //放款审核详情
                    .state('app.loanOrder.loanDetailsReadOnly', {
                        url: '/loanDetailsReadOnly',
                        templateUrl: 'views/loanOrder/loanDetailsReadOnly.html',
                        resolve: {
                            deps: ['uiLoad',
                                '$ocLazyLoad',
                                function(uiLoad, $ocLazyLoad) {
                                    return $ocLazyLoad.load('ui.select').then(function() {
                                        return uiLoad.load(['js/controllers/loanOrder/loanDetailsReadOnly.js']);
                                    });
                                }
                            ]
                        }
                    })


            }
        ]
    );